from django.shortcuts import render

# Create your views here.
from app01 import models

def article(request,*args,**kwargs):
	article_type = models.ArticleType.objects.all()
	article_category = models.Category.objects.all()
	# if request.method == 'GET':
	# 	# article_type = models.ArticleType.objects.all()
	# 	# article_category = models.Category.objects.all()
	# 	articleobj = models.Article.objects.all()
	# 	return render(request,'article.html',{'articleobj':articleobj,'article_type':article_type,'article_category':article_category})
	# elif request.method == 'POST':
	print(kwargs)
	conditions = {}
	for k,v in kwargs.items():
		kwargs[k] = int(v)
		if not v == '0':
			conditions[k] = v
	# article_type = models.ArticleType.objects.all()
	# article_category = models.Category.objects.all()
	articleobj = models.Article.objects.filter(**conditions)
	return render(request,'article.html',{'articleobj':articleobj,'article_type':article_type,'article_category':article_category,'arg_dict':kwargs})
